﻿<%@ page language="C#" autoeventwireup="true" inherits="Admin_UserRight, App_Web_userright.aspx.fdf7a39c" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/main-admin.css" rel="stylesheet" type="text/css" />

    <script src="../Jscript/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../Jscript/page.js" type="text/javascript"></script>

    <script type="text/javascript">






        var userid = <%=id%>;
        function ToSelectP(id) {
            $("#pid" + id).each(function() {
                if ($("#fis" + id).attr('checked') == true) {
                    $(":checkbox", $(this)).each(function() {

                        $(this).attr("checked", true);
                    });
                }
                else {
                    $(":checkbox", $(this)).each(function() {

                        $(this).attr("checked", false);
                    });
                }


            });
        }

        function ToSelectLast(id) {

            var ok = false;
            $("#pid" + id).each(function() {

                $(":checkbox", $(this)).each(function() {

                    if ($(this).attr("checked") == true) {
                        //有1个被选中
                        ok = true;
                    }
                });
            });

            if (ok) {
                $("#fis" + id).attr("checked", true);

            }
            else {
                $("#fis" + id).attr("checked", false);
            }




        }
        function ToSetRight() {

            var id = "";
            $("#tbshow").each(function() {


                $(":checkbox", $(this)).each(function() {

                    if ($(this).attr("checked") == true) {
                        //
                        id += "," + $(this).attr("title");
                    }


                });



            });


            if (id != "") {

                $.post("SetRight.ashx", { Nid: id, Uid: userid }, function(data) {

                    if (data == "ok") {


                        OpenWindow("权限设置成功");
                    }
                    else {
                        OpenWindow(data);

                    }
                });
            }
            else {

                OpenWindow('未选择任何权限');
            }

        }
    </script>

</head>
<body style="height: 800px">
    <form id="form1" runat="server">
    <div class="title-long">
        工作人员管理</div>
    <div style="color: #606; font-weight: bold; float: left; width: 966px; margin-top: 10px;">
        权限设置：<br />
        <br />
    </div>
    <div style="width: 966px; border-bottom: 1px solid #999; float: left; height: 10px;
        height: 600px">
        <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table_style"
            id="tbshow">
            <asp:Repeater ID="classrp" runat="server" OnItemDataBound="classrp_ItemDataBound">
                <ItemTemplate>
                    <tr style="border: 1px solid Red">
                        <td style="width: 65%; color: Blue; font-weight: bold">
                            <input type="checkbox" id='fis<%#Eval("id")%>' onclick="ToSelectP('<%#Eval("id")%>')"
                                title='<%#Eval("id")%>' /><%#Eval("RightName")%>
                        </td>
                    </tr>
                    <tr>
                        <td id='pid<%#Eval("id")%>'>
                            <asp:Repeater ID="last" runat="server">
                                <ItemTemplate>
                                    <input type="checkbox" id='last<%#Eval("id")%>' title='<%#Eval("id")%>' onclick="ToSelectLast('<%#Eval("ParentID")%>')" /><%#Eval("RightName")%>
                                    &nbsp;&nbsp;
                                </ItemTemplate>
                            </asp:Repeater>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <br />
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>
    </div>
    <div style="color: #606; font-weight: bold; float: left; width: 966px; margin-top: 20px;
        text-align: center;">
        <img src="../images/btn-save-userinfo.gif" width="192" height="40" onclick="ToSetRight()" /></div>
    </form>
</body>
</html>
